#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using KLib.Graphics;
#endregion

namespace KLib.Utilities
{
    public class SafeRegionComponent : KLib.DrawableGameComponent
    {
        #region Fields
        SpriteRenderer batch;
        Texture2D tex;
        int width;
        int height;

        int regionWidth;
        int regionHeight;

        Color notSafeColor = new Color(255, 0, 0, 100);
        Color warningColor = new Color(255, 255, 0, 100);
        #endregion

        #region Properties

        #endregion

        #region Initialization

        public SafeRegionComponent(Game game)
            : base(game)
        {
            this.DrawOrder = int.MaxValue - 1;
        }

        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        protected override void LoadContent()
        {
            batch = new SpriteRenderer(GraphicsDevice, Game);
            tex = TextureGenerator.GenerateRectangle(1, 1, Color.White);
            //width = Game.Window.ClientBounds.Width;
            //height = Game.Window.ClientBounds.Height;
            width = GraphicsDevice.Viewport.Width;
            height = GraphicsDevice.Viewport.Height;

            regionHeight =(int)(height * 0.05f);
            regionWidth = (int)(width * 0.05f);
            base.LoadContent();
        }

        #endregion

        #region Methods
        public override void Update(GameTime gameTime)
        {
        }

        public override void Draw(GameTime gameTime)
        {
            batch.Begin(Matrix.Identity);
            //Non Safe Region
            batch.Draw(tex, new Rectangle(0, 0, width, regionHeight), notSafeColor);
            batch.Draw(tex, new Rectangle(0, regionHeight, regionWidth, height - regionHeight*2), notSafeColor);
            batch.Draw(tex, new Rectangle(0, height - regionHeight, width, regionHeight), notSafeColor);
            batch.Draw(tex, new Rectangle(width - regionWidth, regionHeight, regionWidth, height - regionHeight*2), notSafeColor);

            //Warning Region
            batch.Draw(tex, new Rectangle(regionWidth, regionHeight, width - 2 * regionWidth, regionHeight), warningColor);
            batch.Draw(tex, new Rectangle(regionWidth, height - 2 * regionHeight, width - 2 * regionWidth, regionHeight), warningColor);
            batch.Draw(tex, new Rectangle(regionWidth, 2 * regionHeight, regionWidth, height - 4 * regionHeight), warningColor);
            batch.Draw(tex, new Rectangle(width - 2 * regionWidth, 2 * regionHeight, regionWidth, height - 4 * regionHeight), warningColor);
            batch.End();
            base.Draw(gameTime);
        }
        #endregion

        #region Helper Methods

        #endregion
    }
}